var downUrl ;

var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //如果输出结果是true就判定是android终端或者uc浏览器
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //根据输出结果true或者false来判断ios终端


//	安卓
function dong(){
	if (!isAli() && !isWeiXin()) {
		$(".xiazai").css("display","none")
		$("#zhuantu").addClass("container");
		$("#zhuanbei").addClass("huan-loader");
		setTimeout(function(){
			$("#zhuantu").removeClass("container");
			$("#zhuanbei").removeClass("huan-loader");
			$(".xiazai").css("display","block");
			if(isiOS){
				downloadIos();
			}else if(isAndroid){
				downloadApk();
			}
		},1000)
	}else{
		if(isiOS){
			downloadIos();
		}
	}
}


//	iOS
function dong1(){
	if(isAli()){
		//window.location.href = 'https://apps.apple.com/us/app/%E7%94%98%E8%82%83%E5%B9%BF%E7%94%B5/id1493900535?ls=1';
	}else{
		$(".xiazai").css("display","none")
		$("#zhuantu").addClass("container");
		$("#zhuanbei").addClass("huan-loader");
		setTimeout(function(){
			$("#zhuantu").removeClass("container");
			$("#zhuanbei").removeClass("huan-loader");
			$(".xiazai").css("display","block");
			downloadIos();
		},1000)
	}
}


function downloadApk(){
// 	var appData = function (m){
// 		return m;
// 	}
		window.open ("https://dq.zhangxiaoyuan.com.cn/app-release.apk");

	//http://app.gjzwfw.gov.cn/fwmhapp/gjzwfw.apk
	//http://jmpotal.hanweb.com/jmp/app/android/gjzwfw.apk
	//https://appstore.huawei.com/app/C100754945
}


function downloadIos(){

		//window.location.href = "https://apps.apple.com/us/app/%E7%94%98%E8%82%83%E5%B9%BF%E7%94%B5/id1493900535?ls=1";
}




//判断是否是微信浏览器的函数
function isWeiXin(){
  var ua = window.navigator.userAgent.toLowerCase();
  if(ua.match(/MicroMessenger/i) == 'micromessenger'){
	return true;
  }else{
	return false;
  }
}
	
	
	
//判断是支付宝app的浏览器
function isAli(){
	var userAgent = navigator.userAgent.toLowerCase();
    if(userAgent.match(/Alipay/i)=="alipay"){
        return true;
    }else{
        return false;
    }
}		




function requestVersion(appUrl,callback){	
	lightAppJssdk.request.request({
		url: appUrl,
		data: '',
		header: '',
		success: function(data) {
			if(typeof callback == "function") {
				callback(data)
			}
		},
		fail: function(data) {
			var newData = {
							'hasnew':999,
							'msg':'请求失败'
							}	
			if(typeof callback == "function") {
				callback(newData)
			}				

		}
	});
}